<?php
/**
 * 注册验证
 */
session_start();
require "../util/DBUtil.php";

$user = $_POST['userName'];
$password = $_POST['password'];
$gender = $_POST['gender'];
$phone = $_POST['phone'];
$birth = $_POST['birth'];
$address = $_POST['address'];
$relName = $_POST['relName'];
$IDcard = $_POST['IDcard'];


//判断验证码是否正确，不正确还给出提示
$reply = $_POST['reply'];    //验证码
if ($reply != $_SESSION['reply']){
    echo "<script>alert('验证码错误，重新输入');history.back()</script>";
}else{
    $db = new DBUtil();
    $sql = "insert into merchant(account,password,gender,phone,birth,address,merchantName,IDcard) values(?,?,?,?,?,?,?,?)";
    $pram = array($user,$password,$gender,$phone,$birth,$address,$relName,$IDcard);
    $ret = $db->update($sql,$pram);
    if ($ret>0){
        echo "<script>alert('注册成功');location.href='../index.php';</script>";
    }
}

